/* usrd.t   USR_MSTR DELETE TRIGGER                                     */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                   */
/*All rights reserved worldwide.  This is an unpublished work.          */
/*V8:ConvertMode=NoConvert                                              */
/************************************************************************/
/*  Program :usrd.t                                                     */
/*  Author  :Sue Poland                                                 */
/*  Date    :12/16/96                                                   */
/*!
    Description : usr_mstr DELETE TRIGGER


    This routine will, when a usr_mstr record is delete, delete a
    corresponding fsu_mstr record if it exists.

*************************************************************************/
/* REVISION: 8.6      LAST MODIFIED: 12/16/96   BY: *K03G* Sue Poland   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KC* myb          */
/************************************************************************/

TRIGGER PROCEDURE FOR DELETE OF USR_MSTR.

{mfdeclre.i }
define new shared work-table wf_old_usr_mstr like usr_mstr.

if can-find (fsu_mstr where fsu_userid = usr_userid) then do:
    find fsu_mstr where fsu_userid = usr_userid exclusive-lock.
    delete fsu_mstr.
end.

HK:
do:
    if can-find(first dt_mstr where dt_table = "usr_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "DEL", input recid(usr_mstr), input "usr_mstr").

    if not can-find ( first dt_mstr where dt_table = "usr_mstr" and dt_type = "DEL" ) then leave HK.
    
    if not can-find ( first wf_old_usr_mstr ) then do:
        create wf_old_usr_mstr.
        if recid(wf_old_usr_mstr)= -1 then .
    end.
    
    buffer-copy usr_mstr to wf_old_usr_mstr no-error.

    for first dt_mstr no-lock where dt_table = "usr_mstr" and dt_type = "DEL" :
    
    	run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
        	input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
        	input "", input "", input "", input "") .
        	
    end.
end.

{hkdttrans.i}
